package com.lwl.blue.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 示例控制器（用于演示 Swagger 文档生成）
 */
@RestController
@RequestMapping("/demo")
@Api(tags = "示例接口") // 标注控制器功能
public class DemoController {

    @GetMapping("/hello")
    @ApiOperation(value = "简单问候接口", notes = "返回固定的问候语")
    public String hello() {
        return "Hello, Swagger!";
    }

    @GetMapping("/user/{id}")
    @ApiOperation(value = "根据 ID 获取用户信息", notes = "传入用户 ID，返回用户名称")
    @ApiImplicitParam(name = "id", value = "用户 ID", required = true, dataType = "int", paramType = "path")
    public String getUserById(@PathVariable Integer id) {
        return "用户 ID: " + id + "，名称: 测试用户";
    }
}
